package com.wu.dms.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wu.dms.dao.vo.CommentPageVo;
import com.wu.dms.dao.entity.Comment;
import com.wu.dms.dao.sqlProvide.CommentSqlProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Cousin
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @SelectProvider(type = CommentSqlProvider.class, method = "countCommentInPage")
    long countCommentInPage(
            @Param("resourceType") Integer resourceType,
            @Param("searchWord") String searchWord,
            @Param("startDate") String startDate,
            @Param("endDate") String endDate);
    @SelectProvider(type = CommentSqlProvider.class, method = "getCommentInPage")
    List<CommentPageVo> getCommentInPage(@Param("resourceType") Integer resourceType,
                                         @Param("searchWord") String searchWord,
                                         @Param("pageNum") Integer pageNum,
                                         @Param("pageSize") Integer pageSize,
                                         @Param("startDate") String startDate,
                                         @Param("endDate") String endDate);
    @Update(value = "update music.comment set comment.up =#{up} where id = #{id}")
    void updateCommentLikeUp(Long id, Integer up);
    @Update(value = "update music.comment set comment.status = 1 where id = #{id}")
    void deleteComment(Long id);
}
